package com.game.number;

import java.util.Arrays;

/**
 * 
 * @author hp
 *
 */
public class Unit {
	//Coordinate will represent as [1,3], "," is delimate
	private String position;
	
	private String value;
	
	private String[] splitPos;
	
	public Unit(String xy, String value){
		this.position=xy;
		this.value=value;
		splitPos=this.position.split(",");
		
	}
	
	private Unit(String xy, String value, String[] spiltPos){
		this.position=xy;
		this.value=value;
		this.splitPos=Arrays.copyOf(spiltPos, spiltPos.length);
	}
	
	public Unit Clone(){
		Unit newUnit=new Unit(position,value,splitPos);
		return newUnit;
	}
	
	public String getPosition() {
		return position;
	}
	
	public String[] getSplitPosition(){
		return this.splitPos;
	}
	
	public void setPosition(String position) {
		this.position = position;
	}

	public String getValue() {
		return value;
	}

	@Override
	public boolean equals(Object obj){
		if(obj instanceof Unit){
			Unit unitObj=(Unit)obj;
			if(this.position.equals(unitObj.getPosition())&&
					this.value.equals(unitObj.getValue())){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
	
	public String snapshot(){
		return this.position+this.value;
	}
	
}	
